<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/27
 * Time: 11:55
 * 删除新闻
 */

require_once('../db/db.php');

$id=$_REQUEST['id'];//获取id

if(empty($id)){
    echo '参数错误';
    exit;
}

//插入语句
$sql = "DELETE FROM news WHERE id=$id";

try {
    $connect = Db::getInstance()->connect();
} catch(Exception $e) {
    echo '数据库链接失败:'.$e->getMessage();
    exit;
}
$result = mysqli_query($connect,$sql);

if ($result) {
    echo "<script>alert('删除成功');window.location='index.php?'</script>";
} else {
    echo "<script>alert('删除失败');window.history.back();</script>";
}
